import wepy from 'wepy'

export default class testMixin extends wepy.mixin {
    DateDiff(sDate1, sDate2){    //sDate1和sDate2是2002-12-18格式
      var sDate1 = sDate1.replace(/-/g, '/')
      var sDate2 = sDate2.replace(/-/g, '/')  
      var aDate, oDate1, oDate2, iDays
      aDate = sDate1.split("-")
      oDate1 = new Date(aDate[1] + '-' + aDate[2] + '-' + aDate[0])    //转换为12-18-2002格式  
      aDate = sDate2.split("-")
      oDate2 = new Date(aDate[1] + '-' + aDate[2] + '-' + aDate[0])
      iDays = parseInt(Math.abs(oDate1 - oDate2) / 1000 / 60 / 60 / 24)    //把相差的毫秒数转换为天数  
      return iDays
    };
    getWeek(dateStr) {
      var weekDay = ["周天", "周一", "周二", "周三", "周四", "周五", "周六"];
      var dateStrr = dateStr;
      var myDate = new Date(Date.parse(dateStrr.replace(/-/g, "/")));
      return weekDay[myDate.getDay()]
    }
}
